package com.hhb.aopanno;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
@Aspect  //生成一个代理对象
@Order(5)
public class UserProxy {


    //抽取相同的切入点
    @Pointcut(value = "execution(* com.hhb.aopanno.User.add(..))")
    public void pointCut(){

    }


    //前置通知
        //@Before(value = "execution(* com.hhb.aopanno.User.add(..))")
    @Before(value = "execution(* com.hhb.aopanno.*.*(..))")
    public void before(){
        System.out.println("before.....");
    }

    @After(value = "execution(* com.hhb.aopanno.User.add(..))")
    public void after(){
        System.out.println("after.....");
    }

    @Around(value = "pointCut()")
    public void around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        System.out.println("around.....DJ环绕前");

        proceedingJoinPoint.proceed();

        System.out.println("around.....DJ环绕前");
    }

    @AfterReturning(value = "execution(* com.hhb.aopanno.User.add(..))")
    public void afterReturn(){
        System.out.println("afterReturn.....");
    }
}
